/*
 *
 * Copyright (c) 1994
 * Hewlett-Packard Company
 *
 * Permission to use, copy, modify, distribute and sell this software
 * and its documentation for any purpose is hereby granted without fee,
 * provided that the above copyright notice appear in all copies and
 * that both that copyright notice and this permission notice appear
 * in supporting documentation.  Hewlett-Packard Company makes no
 * representations about the suitability of this software for any
 * purpose.  It is provided "as is" without express or implied warranty.
 *
 */
#ifndef LIST_H_INCLUDED
#define LIST_H_INCLUDED

//#include <function.h>
//#include <algobase.h>
//#include <iterator.h>
//#include <bool.h>
//#include <string>
//#include "sqlite3.h"

#ifndef Allocator
#define Allocator allocator
//#include <defalloc.h>
#endif

#ifndef list
#define list list
#endif

#include <cstdlib>
#include <fstream>
#include <string>
#include <algorithm>
#include "dataline.h"
#include "stringtonumb.h"
#include "encoding.h"

#define DEFAULT_PATH "/temp";

namespace STLData{

    class list {
    public:
        dataLine headerValue;
        std::string dtstName;
        std::string dtstPath;

    private:
        std::fstream dtstFile;
        int headerSize;
        int lineSize;
        std::streampos presentLinePos;
        std::streampos nextPos;
        std::string lineCoded;
        std::string fileName;

    public:
        list(std::string filename, std::string filepath);
        list(dataLine variables, std::string dataSetName,
              std::string dataSetPath);

        bool readLine();
        bool modifyLine();
        bool appendLine();
        bool appen(const list other);
        bool sort();
        bool search();
        bool begin();
        bool end();
        list & operator++();
        list & operator++(int);
        list & operator+=(const list &rhs);
        bool sort(std::vector<std::string> sortFields,
                   std::vector<std::string> sortOrder);

    private:
        std::string codeHeader();
        bool decodeLine(const std::string lineString);
    };

}


#undef Allocator
#undef list

#endif // LIST_H_INCLUDED
